package com.xxgc.wujiaosocket.job;

import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Component;

/**
 * @Component 给spring进行管理
 * @Slf4j 打印日志
 */
@Slf4j
@Component
public class HelloJob {

    @Autowired
    private SimpMessagingTemplate messagingTemplate;

    @XxlJob("sayHello")
    public void sayHello(){
        log.info("我被任务调度中心调度了");
    }

    @XxlJob("sayByeBye")
    public void sayByeBye(){
        log.info("下次来玩");
    }

    @XxlJob("liveMessage")
    public void liveMessage(){
        //订阅地址
        String path = "/wujiao/live";
        //发送消息
        String json = """
                {"code":0,"nickname":"官方助手","level":99,"avatar":"https://picsum.photos/200/200","content":"给主播点点关注点点赞"}
                """;
        log.info("调用成功了吗11");
        messagingTemplate.convertAndSend(path,json);
    }


}
